describe("Modulo exponentiation", function()
	local modpow = require("math.modpow")
	describe("edge cases", function()
		it("1 if exponent is 0", function()
			assert.equal(1, modpow(42, 0, 42))
		end)
		it("0 if base is 0", function()
			assert.equal(0, modpow(0, 42, 42))
		end)
		it("throws if exponent = base = 0", function()
			assert.has_error(function()
				return modpow(0, 0, 42)
			end)
		end)
	end)
	it("matches `base^exp % mod` for small exponents & bases", function()
		for _ = 1, 1e3 do
			local exp, base = math.random(1, 7), math.random(2, 10)
			local mod = math.random(1e2, 1e7)
			assert(modpow(base, exp, mod) == base ^ exp % mod)
		end
	end)
	it("works for large exponents & bases", function()
		assert.equal(783217, modpow(123456789, 987654321, 1000007))
	end)
end)
